package com.hackerrank.challenges.pickingcards;

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		for(int t = 0; t < T; t++) {
			int N = in.nextInt(), c[] = new int[N + 1];
			for(int n = 0; n < N; n++)
				c[in.nextInt()]++;
			long r = 0, w = 1, tc = 0;
			for(int n = 0; w > 0 && n < N; n++) {
				tc += c[n];
				r += c[n];
				w = (w * r) % 1000000007;
				r--;
			}
			if(tc < N)
				System.out.println(0);
			else
				System.out.println(w);
		}
	}
}
